/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;


import Controller.ReadCreditCardSIM;
import Controller.ReadDPI;
import Model.CreditCardInfo;
import Model.DPIinfo;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JPanel;

/**
 *
 * @author giovannirojas
 */
public class IndexPOS extends javax.swing.JFrame {

    /**
     * Creates new form IndexPOS
     */
    private Image photoDPI = null;
    private DPIinfo infoDPI = null;
    
    // Para las tarjetas de Credito 
    private CreditCardInfo infoCard = null;
    Image photoCard = null;
    
    
    public IndexPOS() {
        
        initComponents();
        blankFieldRegistration();
        blankFieldSIM();
        blankFieldMagnetic();
        
        
        // Tengo que colocar otra foto para que sea mejor manejado. 
        this.photoDPI =  Toolkit.getDefaultToolkit().createImage(getClass().getResource("/Images/unknown.png"));
        this.photoCard = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/Images/unknown.png"));
        
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        containerPanels = new javax.swing.JTabbedPane();
        InicioTab = new javax.swing.JPanel();
        RegistroTab = new javax.swing.JPanel();
        jPanel1 = new JPanel(){

            public void paintComponent(Graphics gio)
            {
                super.paintComponent(gio);
                if(photoDPI != null) {
                    gio.drawImage(photoDPI, (this.getWidth()-photoDPI.getWidth(null))/2, (this.getHeight()-photoDPI.getHeight(null))/2, this);
                }
            };
        }
        ;
        nameField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        apellidoField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        dpiField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        mailField = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        readDPI = new javax.swing.JButton();
        cobroTab = new javax.swing.JPanel();
        jPanel2 = new JPanel(){

            public void paintComponent(Graphics gio)
            {
                super.paintComponent(gio);
                if(photoCard != null) {
                    gio.drawImage(photoCard, (this.getWidth()-photoCard.getWidth(null))/2, (this.getHeight()-photoCard.getHeight(null))/2, this);
                }
            };
        }
        ;
        nameCard = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        numberCard = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        dateCard = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        chargeCard = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        readCreditCard = new javax.swing.JButton();
        cobroMagnetica = new javax.swing.JPanel();
        jPanel3 = new JPanel();
        ;
        nameCard1 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        numberCard1 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        dateCard1 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        chargeCard1 = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        readCreditCard1 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        containerPanels.setPreferredSize(new java.awt.Dimension(576, 700));

        InicioTab.setBackground(new java.awt.Color(255, 255, 255));

        org.jdesktop.layout.GroupLayout InicioTabLayout = new org.jdesktop.layout.GroupLayout(InicioTab);
        InicioTab.setLayout(InicioTabLayout);
        InicioTabLayout.setHorizontalGroup(
            InicioTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 522, Short.MAX_VALUE)
        );
        InicioTabLayout.setVerticalGroup(
            InicioTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 632, Short.MAX_VALUE)
        );

        containerPanels.addTab("Inicio", InicioTab);

        jPanel1.setBackground(new java.awt.Color(128, 128, 128));

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 230, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 0, Short.MAX_VALUE)
        );

        nameField.setText("Geovanni Gerardo Rodolfo Eduardo");
        nameField.setEnabled(false);

        jLabel2.setText("Nombre :");

        jLabel3.setText("Apellido :");

        apellidoField.setText("Rojas Mazariegos");
        apellidoField.setEnabled(false);

        jLabel4.setText("DPI :");

        dpiField.setText("2340667410101");
        dpiField.setEnabled(false);

        jLabel5.setText("Correo :");

        mailField.setText("geovaroma@gmail.com");
        mailField.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mailFieldMouseClicked(evt);
            }
        });

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/newOne.png"))); // NOI18N
        jButton1.setText("Registrar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancel.png"))); // NOI18N
        jButton2.setText("Cancelar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        readDPI.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/registration.png"))); // NOI18N
        readDPI.setText("<html>Leer<br>DPI");
        readDPI.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                readDPIActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout RegistroTabLayout = new org.jdesktop.layout.GroupLayout(RegistroTab);
        RegistroTab.setLayout(RegistroTabLayout);
        RegistroTabLayout.setHorizontalGroup(
            RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(RegistroTabLayout.createSequentialGroup()
                .addContainerGap()
                .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(RegistroTabLayout.createSequentialGroup()
                        .add(readDPI, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jButton1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButton2)
                        .add(0, 0, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, RegistroTabLayout.createSequentialGroup()
                        .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(RegistroTabLayout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(RegistroTabLayout.createSequentialGroup()
                                        .add(6, 6, 6)
                                        .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, apellidoField)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, nameField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, dpiField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, RegistroTabLayout.createSequentialGroup()
                                .add(12, 12, 12)
                                .add(mailField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(18, Short.MAX_VALUE))))
        );

        RegistroTabLayout.linkSize(new java.awt.Component[] {jButton1, jButton2, readDPI}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        RegistroTabLayout.setVerticalGroup(
            RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(RegistroTabLayout.createSequentialGroup()
                .addContainerGap()
                .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(RegistroTabLayout.createSequentialGroup()
                        .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(nameField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(apellidoField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(dpiField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mailField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(6, 6, 6))
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(18, 18, 18)
                .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(RegistroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(readDPI, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(219, Short.MAX_VALUE))
        );

        RegistroTabLayout.linkSize(new java.awt.Component[] {jButton1, jButton2, readDPI}, org.jdesktop.layout.GroupLayout.VERTICAL);

        RegistroTabLayout.linkSize(new java.awt.Component[] {apellidoField, dpiField, mailField, nameField}, org.jdesktop.layout.GroupLayout.VERTICAL);

        containerPanels.addTab("Registro", RegistroTab);

        jPanel2.setBackground(new java.awt.Color(128, 128, 128));

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 230, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 0, Short.MAX_VALUE)
        );

        nameCard.setText("Geovanni Gerardo Rodolfo Eduardo");
        nameCard.setEnabled(false);

        jLabel6.setText("Nombre Tarjeta :");

        jLabel7.setText("Número Tarjeta :");

        numberCard.setText("XXXX-XXXX-XXXX-XXXX");
        numberCard.setEnabled(false);

        jLabel8.setText("Fecha de Vencimiento :");

        dateCard.setText("01/12");
        dateCard.setEnabled(false);

        jLabel9.setText("Monto a cobrar :");

        chargeCard.setText("12.2");
        chargeCard.setFocusable(false);

        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/money.png"))); // NOI18N
        jButton3.setText("Cobrar");

        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancel.png"))); // NOI18N
        jButton4.setText("Cancelar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        readCreditCard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/smartCard.png"))); // NOI18N
        readCreditCard.setText("<html>Leer<br>Tarjeta de <br> crédito");
        readCreditCard.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                readCreditCardActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout cobroTabLayout = new org.jdesktop.layout.GroupLayout(cobroTab);
        cobroTab.setLayout(cobroTabLayout);
        cobroTabLayout.setHorizontalGroup(
            cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(cobroTabLayout.createSequentialGroup()
                .addContainerGap()
                .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cobroTabLayout.createSequentialGroup()
                        .add(readCreditCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jButton3)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButton4)
                        .add(0, 0, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, cobroTabLayout.createSequentialGroup()
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(cobroTabLayout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(cobroTabLayout.createSequentialGroup()
                                        .add(6, 6, 6)
                                        .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, numberCard)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, nameCard, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, dateCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel8)))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, cobroTabLayout.createSequentialGroup()
                                .add(12, 12, 12)
                                .add(chargeCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(18, Short.MAX_VALUE))))
        );

        cobroTabLayout.linkSize(new java.awt.Component[] {jButton3, jButton4, readCreditCard}, org.jdesktop.layout.GroupLayout.HORIZONTAL);

        cobroTabLayout.setVerticalGroup(
            cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(cobroTabLayout.createSequentialGroup()
                .addContainerGap()
                .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(cobroTabLayout.createSequentialGroup()
                        .add(jLabel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(nameCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(numberCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(dateCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel9, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(chargeCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(6, 6, 6))
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(18, 18, 18)
                .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cobroTabLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jButton4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(readCreditCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(219, Short.MAX_VALUE))
        );

        cobroTabLayout.linkSize(new java.awt.Component[] {jButton3, jButton4, readCreditCard}, org.jdesktop.layout.GroupLayout.VERTICAL);

        containerPanels.addTab("Tarjeta SIM", cobroTab);

        jPanel3.setBackground(new java.awt.Color(128, 128, 128));

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 230, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 0, Short.MAX_VALUE)
        );

        nameCard1.setText("Geovanni Gerardo Rodolfo Eduardo");
        nameCard1.setEnabled(false);
        nameCard1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nameCard1ActionPerformed(evt);
            }
        });

        jLabel10.setText("Nombre Tarjeta :");

        jLabel11.setText("Número Tarjeta :");

        numberCard1.setText("XXXX-XXXX-XXXX-XXXX");
        numberCard1.setEnabled(false);

        jLabel12.setText("Fecha de Vencimiento :");

        dateCard1.setText("01/12");
        dateCard1.setEnabled(false);

        jLabel13.setText("Monto a cobrar :");

        chargeCard1.setText("12.2");
        chargeCard1.setFocusable(false);

        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/cancel.png"))); // NOI18N
        jButton6.setText("Cancelar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        readCreditCard1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/smartCard.png"))); // NOI18N
        readCreditCard1.setText("<html>Leer<br>Tarjeta de <br> crédito");
        readCreditCard1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                readCreditCard1ActionPerformed(evt);
            }
        });

        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/money.png"))); // NOI18N
        jButton7.setText("Cobrar");

        org.jdesktop.layout.GroupLayout cobroMagneticaLayout = new org.jdesktop.layout.GroupLayout(cobroMagnetica);
        cobroMagnetica.setLayout(cobroMagneticaLayout);
        cobroMagneticaLayout.setHorizontalGroup(
            cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(cobroMagneticaLayout.createSequentialGroup()
                .addContainerGap()
                .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cobroMagneticaLayout.createSequentialGroup()
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(cobroMagneticaLayout.createSequentialGroup()
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 110, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(cobroMagneticaLayout.createSequentialGroup()
                                        .add(6, 6, 6)
                                        .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, numberCard1)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, nameCard1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, dateCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel12)))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, cobroMagneticaLayout.createSequentialGroup()
                                .add(12, 12, 12)
                                .add(chargeCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 256, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                    .add(cobroMagneticaLayout.createSequentialGroup()
                        .add(readCreditCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(jButton7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(jButton6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        cobroMagneticaLayout.setVerticalGroup(
            cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(cobroMagneticaLayout.createSequentialGroup()
                .addContainerGap()
                .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(cobroMagneticaLayout.createSequentialGroup()
                        .add(jLabel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(nameCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(numberCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(dateCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(jLabel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(chargeCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(6, 6, 6))
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(18, 18, 18)
                .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cobroMagneticaLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jButton7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(readCreditCard1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 61, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(219, Short.MAX_VALUE))
        );

        containerPanels.addTab("Tarjeta Magnetica", cobroMagnetica);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(containerPanels, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 543, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 17, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(containerPanels, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 678, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void readDPIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readDPIActionPerformed
        // antes que nada voy a blanquear lo que tengo 
        blankFieldRegistration();
        ReadDPI read = new ReadDPI();
        
        // Esto es para tener una especie de hilo para que cuando este haciendo el proceso de lectura. 
        while (!read.isReaded()){
            photoDPI =  Toolkit.getDefaultToolkit().createImage(getClass().getResource("/Images/loading.gif"));
            repaint();
            infoDPI=read.readDPI();
        }
        
        if(infoDPI!= null)
            putDataRegistation(infoDPI);
        else 
            blankFieldRegistration();
        
    }//GEN-LAST:event_readDPIActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton4ActionPerformed

    private void readCreditCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readCreditCardActionPerformed
        blankFieldSIM();
        ReadCreditCardSIM card  = new ReadCreditCardSIM();
        // Esto es para darle un efecto de espera al proceso. 
        while (!card.isReaded()){
            photoCard =  Toolkit.getDefaultToolkit().createImage(getClass().getResource("/Images/loading.gif"));
            repaint();
            infoCard = card.readCard(); 
        }
        if (infoCard!=null)
            putDataSIM(infoCard);
        else 
            blankFieldSIM();
    }//GEN-LAST:event_readCreditCardActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton6ActionPerformed

    private void mailFieldMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mailFieldMouseClicked
        KeyboardTouch va = new KeyboardTouch(this,true,mailField);
        va.setLocationRelativeTo(null);
        va.setVisible(true);
    }//GEN-LAST:event_mailFieldMouseClicked

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton1ActionPerformed

    private void nameCard1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameCard1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nameCard1ActionPerformed

    private void readCreditCard1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readCreditCard1ActionPerformed
        
        blankFieldMagnetic();
        MagneticReader mcr = new MagneticReader(this,true,nameCard1, numberCard1, dateCard1);
        mcr.setLocationRelativeTo(null);
        mcr.setVisible(true);
    }//GEN-LAST:event_readCreditCard1ActionPerformed


    
/*
 * Los siguientes metodos conciernen a todo 
 * lo que sea de <Registro>
 */    
    
/*
 * Lo que hace esto es colocar cuando necesite el loading 
 * si la imagen ya cargo entonces colocare la imagen del sujeto 
 * sino pues mando verdadero y coloco el loading. 
 */ 
private void putImageRegistration(boolean loading){
    
    {
        if (loading)
            this.photoDPI = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/Images/unknown.png"));
        else 
            this.photoDPI = infoDPI.getPhoto(); 
        repaint();
    }
    
    }
 /*
 * Lo que hace esto es poner los datos en blanco. 
 */  
private void blankFieldRegistration(){
    nameField.setText("");
    apellidoField.setText("");
    dpiField.setText("");
    mailField.setText("");
    putImageRegistration(true);
    
    
}    
/*
 * Lo que  hace este metodo es colocar toda la informacion de 
 * la persona en los campos segun sea el caso. 
 */    
private void putDataRegistation(DPIinfo info){
        nameField.setText(info.getPrimerNombre().replace("  ", "")+" "+info.getSegundoNombre().replace("  ", "")+" "+info.getTercerNombre().replace("  ", ""));
        apellidoField.setText(info.getPrimerApellido().replace("  ", "")+" "+info.getSegundoApellido().replace("  ", ""));
        dpiField.setText(info.getDpi());
        putImageRegistration(false);
        
}

// <Fin de Registro>


/*
 * Los siguientes metodos conciernen a todo 
 * lo que sea de <Cobro con SIM>
 */    
    
/*
 * Lo que hace esto es colocar cuando necesite el loading 
 * si la imagen ya cargo entonces colocare la imagen del sujeto 
 * sino pues mando verdadero y coloco el loading. 
 */ 
private void putImageSIM(boolean loading){
    
    {
        if (loading)
            this.photoCard = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/Images/unknown.png"));
        else 
            this.photoCard = infoCard.getPhoto(); // have to work on it 
        repaint();
    }
    
    }
 /*
 * Lo que hace esto es poner los datos en blanco. 
 */  
private void blankFieldSIM(){
    nameCard.setText("");
    numberCard.setText("");
    dateCard.setText("");
    chargeCard.setText("");
    putImageSIM(true);
    
    
}    
/*
 * Lo que  hace este metodo es colocar toda la informacion de 
 * la persona en los campos segun sea el caso. 
 */    
private void putDataSIM(CreditCardInfo info){
        nameCard.setText(info.getNombreTarjeta().replace("  ", ""));
        
        String cardNumber = String.valueOf(info.getNumeroTarjeta());
        numberCard.setText(cardNumber.substring(0,4)+"-"+cardNumber.substring(4,8)+"-"+cardNumber.substring(8,12)+"-"+cardNumber.substring(12,16));
        
        
        dateCard.setText(String.valueOf(info.getMesFin())+"/"+String.valueOf(info.getAnioFin()));
        putImageSIM(false);
        
}

// <Fin de Cobro con SIM>

/*
 * Lo que hace esto es poner los datos en blanco. 
 */  
private void blankFieldMagnetic(){
    nameCard1.setText("");
    numberCard1.setText("");
    dateCard1.setText("");
    chargeCard1.setText("");
    putImageSIM(true);
    
    
}

/*
 * Lo que  hace este metodo es colocar toda la informacion de 
 * la persona en los campos segun sea el caso. 
 */    

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IndexPOS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IndexPOS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IndexPOS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IndexPOS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new IndexPOS().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel InicioTab;
    private javax.swing.JPanel RegistroTab;
    private javax.swing.JTextField apellidoField;
    private javax.swing.JTextField chargeCard;
    private javax.swing.JTextField chargeCard1;
    private javax.swing.JPanel cobroMagnetica;
    private javax.swing.JPanel cobroTab;
    private javax.swing.JTabbedPane containerPanels;
    private javax.swing.JTextField dateCard;
    private static javax.swing.JTextField dateCard1;
    private javax.swing.JTextField dpiField;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField mailField;
    private javax.swing.JTextField nameCard;
    private static javax.swing.JTextField nameCard1;
    private javax.swing.JTextField nameField;
    private javax.swing.JTextField numberCard;
    private static javax.swing.JTextField numberCard1;
    private javax.swing.JButton readCreditCard;
    private javax.swing.JButton readCreditCard1;
    private javax.swing.JButton readDPI;
    // End of variables declaration//GEN-END:variables
}
